import { Component } from '@angular/core';
import { NavController, ActionSheetController } from 'ionic-angular';

@Component({
  selector: 'page-action-sheets',
  templateUrl: 'action-sheets.html'
})

// https://ionicframework.com/docs/api/components/action-sheet/ActionSheetController/
export class ActionSheetsPage {

  constructor(public navCtrl: NavController, public actionSheetCtrl: ActionSheetController) {

  }

  actionSheet1() {
    let actionSheet = this.actionSheetCtrl.create({
      // title: 'Title',
      // subTitle: 'SubTitle',
      // enableBackdropDismiss: false,
      buttons: [
        {
          text: '从相册获取图片',
          handler: () => {
            console.log('从相册选取图片');
          }
        },
        {
          text: '从相机获取图片',
          handler: () => {
            console.log('从相机获取图片');
          }
        },
        {
          text: '返回',
          handler: () => {
            let navTransition = actionSheet.dismiss();
            navTransition.then(() => {
              this.navCtrl.pop();
            });
            return false;
          }
        },
        {
          text: '取消',
          role: 'cancel',
          handler: () => {
            console.log('取消')
          }
        }
      ]
    });
    actionSheet.present();
  }
}
